package com.reflect.study;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class Test5 {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<>();
        list.add("aaa");

        // 使用反射越过泛型检查
        Class<?> listClass = list.getClass();
        Method method = listClass.getDeclaredMethod("add", Object.class);
        method.invoke(list, 1);
        System.out.println(list);
    }
}
